package add;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    static int N = 100010;
    static int[] s = new int[N];

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        HashMap<Character, Integer> map = new HashMap<>();
        int n = in.nextInt();
        String str = in.next();
        for (int i = 1; i < N; i++) {
            s[i] = s[i - 1] + i;
        }
        for (int i = 0; i < n; i++) {
            char ch = str.charAt(i);
            if (map.containsKey(ch)) {
                map.put(ch, map.get(ch) + 1);
            } else {
                map.put(ch, 1);
            }
        }
        long res = 0;
        for (int i = 0; i < n; i++) {
            char ch = str.charAt(i);
            map.put(ch, map.get(ch) - 1);
            for (Map.Entry<Character, Integer> entry : map.entrySet()) {
                if (entry.getKey() != ch) {
                    if(entry.getValue()>0){
                        res += s[entry.getValue() - 1];
                    }
                }
            }
        }
        System.out.println(res);
    }
}